package com.getan.boot.module.system.controller;

import com.getan.boot.common.ResponseBuilder;
import com.getan.boot.common.ResponseCodeData;
import com.getan.boot.common.encrypt.JasyptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户管理
 *
 * @author Bruce.Gong
 * @since 1.0.0-SNAPSHOT
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/common")
public class CommonController {

    private final JasyptService jasyptService;

    @GetMapping("encode")
    public ResponseCodeData<String> encode(@RequestParam String code) {
        return ResponseBuilder.ok(jasyptService.encrypt(code));
    }

    @GetMapping("decode")
    public ResponseCodeData<String> decode(@RequestParam String code) {
        return ResponseBuilder.ok(jasyptService.decrypt(code));
    }

}
